Dataset Previews
First, initialize by adding tools and declare floating type
using GriddingMachine
using PkgUtility
using Plots
using Plots.PlotMeasures
ENV["GKSwstype"]="100";
FT = Float32;
# use this to fix the problem in generated preview.jl file
F1 = joinpath(@__DIR__, "../../Artifacts.toml");
F2 = joinpath(@__DIR__, "../../../Artifacts.toml");
GRIDDINGMACHINE_ARTIFACTS = (isfile(F1) ? F1 : F2);
predownload_artifact.(["GPP_MPI_v006_1X_8D", "GPP_VPM_v20_1X_8D",
"NPP_MODIS_1X_1Y", "canopy_height_20X_1Y",
"clumping_index_12X_1Y", "clumping_index_2X_1Y_PFT",
"land_mask_ERA5_4X_1Y", "leaf_area_index_4X_1M",
"leaf_chlorophyll_2X_7D", "leaf_traits_2X_1Y",
"river_maps_4X_1Y", "SIF_TROPOMI_740_1X_1M",
"surface_data_2X_1Y", "tree_density_12X_1Y",
"wood_density_2X_1Y"],
GRIDDINGMACHINE_ARTIFACTS);#=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # -=#=# # # 0.0% 0.1% 0.3% 1.0% ## 3.9% ######### 12.7% ################ 22.7% ####################### 32.4% ############################ 39.2% ############################## 42.6% #################################### 50.3% ########################################## 58.6% ############################################### 66.0% ################################################## 69.5% ##################################################### 74.1% ######################################################## 79.1% ########################################################### 82.6% ############################################################### 88.3% ################################################################## 91.8% #################################################################### 95.4% ####################################################################### 99.1% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # -=#=# # # -=O#- # # # -=O=# # # # -=O=-# # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # -=O=- # # # # 0.0% 0.1% 0.5% # 1.7% ### 5.5% ####### 10.0% ########## 14.7% ############## 19.8% ################## 25.2% ###################### 31.0% ########################## 37.2% ############################### 43.7% #################################### 50.8% ########################################## 58.5% ############################################### 66.6% ###################################################### 75.4% ############################################################# 84.9% #################################################################### 95.1% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # ###################### 30.9% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 0.4% # 2.4% ##### 7.0% ################### 26.9% ################################################################### 94.4% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 1.2% ### 5.5% ########## 15.2% ##################################### 51.9% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # # 2.0% ####### 10.9% ################## 25.5% ########################################################### 82.6% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # ## 3.0% ######### 13.6% ####################### 32.3% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 0.2% 0.8% ## 3.2% ######## 12.1% ############################### 44.0% ############################################################## 87.3% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 0.2% 0.9% ## 3.5% ######### 13.5% #################################### 50.5% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 1.0% ##### 7.3% ############ 17.2% ############################################### 65.3% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 0.3% # 2.1% ### 5.3% ############# 18.5% ############################################### 66.6% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 0.1% 0.5% # 2.1% ##### 7.5% ################## 26.1% ################################### 49.9% ###################################################### 75.4% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 0.0% 0.1% 0.2% 0.5% # 1.8% ### 4.9% ##### 8.3% ######## 11.8% ########### 15.7% ############## 19.7% ################# 24.0% #################### 28.7% ######################## 33.7% ############################ 39.1% ################################ 44.8% #################################### 50.9% ######################################### 57.2% ############################################# 63.4% ################################################## 69.7% ###################################################### 76.0% ########################################################### 82.1% ############################################################### 87.7% ################################################################### 93.4% ####################################################################### 99.6% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # 0.3% # 1.5% ## 3.5% ########## 14.7% ####################################### 54.6% ######################################################################## 100.0% #=#=# ##O#- # ##O=# # #=#=-# # -#O#- # # # 2.8% ###### 8.6% ########################### 38.1% ######################################################################## 100.0%
Then, define a function to plot the dataset
function preview_data(ds::GriddedDataset{FT}, ind::Int)
# preview data
return heatmap(view(ds.data,:,:,ind)',
origin="lower",
aspect_ratio=1,
xticks=[],
yticks=[],
c=:viridis,
size=(700,300),
framestyle=:none)
end
function preview_data(ds::GriddedDataset{FT}, ind::Int, clim::Tuple)
# preview data
return heatmap(view(ds.data,:,:,ind)',
origin="lower",
aspect_ratio=1,
xticks=[],
yticks=[],
c=:viridis,
clim=clim,
size=(700,300),
framestyle=:none)
endpreview_data (generic function with 2 methods)
Leaf level datasets
Leaf chlorophyll content
LCH_LUT = load_LUT(LeafChlorophyll{FT}());
mask_LUT!(LCH_LUT, FT[0,Inf]);
LCH_LUT = regrid_LUT(LCH_LUT, Int(size(LCH_LUT.data,2)/180));
anim = @animate for i ∈ 1:size(LCH_LUT.data,3)
preview_data(LCH_LUT, i, (0,80));
end
gif(anim, fps=5)Leaf nitrogen content
LNC_LUT = load_LUT(LeafNitrogen{FT}());
mask_LUT!(LNC_LUT, FT[0,Inf]);
LNC_LUT = regrid_LUT(LNC_LUT, Int(size(LNC_LUT.data,2)/180));
preview_data(LNC_LUT, 1)
Leaf phosphorus content
LPC_LUT = load_LUT(LeafPhosphorus{FT}());
mask_LUT!(LPC_LUT, FT[0,Inf]);
LPC_LUT = regrid_LUT(LPC_LUT, Int(size(LPC_LUT.data,2)/180));
preview_data(LPC_LUT, 1)
Specific leaf area
SLA_LUT = load_LUT(LeafSLA{FT}());
mask_LUT!(SLA_LUT, FT[0,Inf]);
SLA_LUT = regrid_LUT(SLA_LUT, Int(size(SLA_LUT.data,2)/180));
preview_data(SLA_LUT, 1)
Vcmax
VCM_LUT = load_LUT(VcmaxOptimalCiCa{FT}());
mask_LUT!(VCM_LUT, FT[0,Inf]);
VCM_LUT = regrid_LUT(VCM_LUT, Int(size(VCM_LUT.data,2)/180));
preview_data(VCM_LUT, 1)
Stand level datasets
Canopy height
CHT_LUT = load_LUT(CanopyHeightGLAS{FT}());
mask_LUT!(CHT_LUT, FT[0,Inf]);
CHT_LUT = regrid_LUT(CHT_LUT, Int(size(CHT_LUT.data,2)/180));
preview_data(CHT_LUT, 1)
Clumping index
# global clumping index
CLI_LUT = load_LUT(ClumpingIndexMODIS{FT}(), "12X", "1Y");
mask_LUT!(CLI_LUT, FT[0,1]);
CLI_LUT = regrid_LUT(CLI_LUT, Int(size(CLI_LUT.data,2)/180));
preview_data(CLI_LUT, 1, (0.4,1))
# global clumping index per PFT
CLI_LUT = load_LUT(ClumpingIndexPFT{FT}());
mask_LUT!(CLI_LUT, FT[0,1]);
CLI_LUT = regrid_LUT(CLI_LUT, Int(size(CLI_LUT.data,2)/180));
anim = @animate for i ∈ 1:size(CLI_LUT.data,3)
preview_data(CLI_LUT, i, (0.4,1));
end
gif(anim, fps=1)Gross primary productivity
# GPP MPI
anim = @animate for year ∈ 2001:2019, i ∈ 1:46
GPP_LUT = load_LUT(GPPMPIv006{FT}(), year, "1X", "8D");
mask_LUT!(GPP_LUT, FT[-100,Inf]);
preview_data(GPP_LUT, i, (0,10));
end
gif(anim, fps=20)